﻿using System;
using System.ComponentModel.DataAnnotations;
using Epam.PeopleInterfaces;

namespace Epam.PeopleModel
{
    public class PeopleEntity:IPeopleEntity
    {
        public Guid Id { get;private set; }

        [Required]
        [RegularExpression("[0-9a-zA-Z -]{1,50}", ErrorMessage = "Invalid name")]
        public string Name { get; private set; }

        [Required]
        [DateFormat(ErrorMessage = "Invalid date format")]
        [DateRange(MinDate = "01/01/1920", ErrorMessage = "Date must have range 1920-2012")]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}",ApplyFormatInEditMode = true)]
        public DateTime BirthDate { get; private set; }

        [Required]
        [Range(2,400,ErrorMessage = "This argument out of range")]
        public double Weight { get; private set; }

        [Required]
        [Range(30, 300, ErrorMessage = "This argument out of range")]
        public double Height { get; private set; }

        public PeopleEntity(Guid id,string name,DateTime birthdate,double weight,double height)
        {
            Id=id;
            Name = name;
            BirthDate = birthdate;
            Weight = weight;
            Height = height;
        }

        public PeopleEntity()
        {
            Id=Guid.Empty;
            Name = string.Empty;
            BirthDate=DateTime.Now;
            Weight = 0;
            Height = 0;
        }
    }
}
